import request from '@/utils/request.js'

/**
 * 获取所有角色列表
 * @returns
 */
export const getRoleData = (params) => {
  return request({
    url: '/sys/role',
    params
  })
}

/**
 * 根据ID删除角色
 * @returns
 */
export const delRoleData = (id) => {
  return request({
    url: '/sys/role/' + id,
    method: 'DELETE'
  })
}

/**
 * 根据ID更新角色
 * @returns
 */
export const editRoleData = (data) => {
  return request({
    url: '/sys/role/' + data.id,
    method: 'PUT',
    data
  })
}

/**
 * 添加角色
 * @returns
 */
export const addRoleData = (data) => {
  return request({
    url: '/sys/role',
    method: 'POST',
    data
  })
}

/**
 * 根据ID获取角色详情
 * @returns
 */
export const getRoleById = (id) => {
  return request({
    url: '/sys/role/' + id,
    method: 'GET'
  })
}

/**
 * 给角色分配权限
 * @returns
 */
export const setRole = (data) => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'PUT',
    data
  })
}
